<?php

namespace app\admin\validate;

use think\Validate;

class House extends Validate
{
    protected $rule = [
        'id' => 'require',
        'status' => 'require|checkStatus',
        'sort' => 'require',
        'pid' => 'require',
        'name' => 'require',
    ];

    protected $scene=[
        'create'=>['status','sort','name'],
        'update'=>['id','status','sort','name'],
    ];

    protected $message = [
        'id' => 'id不能为空',
        'status' => '状态不能为空',
        'sort' => '排序不能为空',
        'pid' => '上级不能为空',
        'name' => '名称不能为空',

    ];
    protected function checkStatus($value){
        if(!in_array($value,[0,1])){
            return '状态错误';
        }
        return true;
    }
}
